﻿@using CRM.Admin.Contracts.Model.Sys;
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <title>客户信息云平台-首页</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="Bookmark" href="@Url.Content("~/Icons/favicon.ico")" />
    <link rel="shortcut icon" href="@Url.Content("~/Icons/favicon.ico")" type="image/x-icon" />
    <link href="@Url.Content("~/App_Themes/reset.css")" rel="stylesheet" />
    <link href="@Url.Content("~/App_Themes/default/css/index.css")" rel="stylesheet" />
    <link href="@Url.Content("~/App_Themes/default/css/commcon.css")" rel="stylesheet" />
    <link href="@Url.Content("~/App_Themes/default/css/animation.css")" rel="stylesheet" />
    <link href="@Url.Content("~/ScriptPlugin/layer/layer.css")" rel="stylesheet" />
    <link href="@Url.Content("~/App_Themes/default/icons/iconcontent/iconfont.css")" rel="stylesheet" type="text/css"/>
    <script src="@Url.Content("~/Scripts/jquery-1.11.3.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/KingsSharp.js")" type="text/javascript"></script>
    <script type="text/javascript" src="@Url.Content("~/ScriptPlugin/xlayer/layer.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/jquery.validate.extended.js")"></script>
    <script type="text/javascript">
        var index;
        function pageLoad() {
            layer.close(index);
        }
    </script>
    <style type="text/css">
        .sp {
            display: inline-block;
            margin: 20px 10px 10px 20px;
        }

        .txt {
            width: 180px;
            height: 30px;
            margin: 20px 0 10px 10px;
            border: 1px solid #a4b6d5;
        }

        .btn {
            margin: 20px 0 0 100px;
        }

        .editbtn {
            width: 70px;
            height: 30px;
            background-color: #2e8ded;
            border: 1px solid #4898d5;
            color: #fff;
            border-radius: 2px;
        }

        .regbtn {
            width: 70px;
            height: 30px;
            background-color: #f1f1f1;
            border: 1px solid #dedede;
            color: #333;
            border-radius: 2px;
        }
    </style>
</head>
@model List<MenuCatalog>
<body onload="pageLoad()" style="overflow:hidden;">
    <script type="text/javascript">
        index = layer.msg("玩命加载中...", { icon: 16, shade: 0.4, time: false });
    </script>
    <div class="index-header">
        <div class="topbar">
            <div class="logbar"><img src="@Url.Content("~/Images/logo.png")" style="width:250px;height:50px" /><h1 style="font-size:24px;display:none">&nbsp;&nbsp;</h1></div>
            <div class="tagbar">
                <div class="tabs-container">
                    <span style="float:left"></span>
                    <ul id="taglist">
                        <li id="tag_0" class="selected" onclick="Showtag(0)"><i class="icon iconfont" style="color:#F76D63">&#xe61d;</i>主工作台</li>
                    </ul>
                    <span style="float:right"></span>
                </div>
            </div>
            <div class="infobar">
                <ul>
                    <li>
                        @if (string.IsNullOrWhiteSpace(ViewBag.PortraitURL))
                        {
                            <img class="infouser" src="@Url.Content("~/Images/noportrait.png")" style="width:35px;height:35px;margin-top:7px;float:left" />
                        }
                        else
                        {
                            <img class="infouser" src="@Url.Content("~/" + ViewBag.PortraitURL)" style="width:35px;height:35px;margin-top:7px;float:left" />
                        }
                        <div style="float:left;width:auto;padding-left:3px;">@AppVariable.UserData.UserName</div>
                        <div style="float:left;width:auto;padding-left:10px;"><i class="icon iconfont" style="font-size:12px">&#xe628;</i></div>
                        <ul class="dropdown-menu userMenu">
                            <li><a href="javascript:;" id="updatePwd">修改密码</a></li>
                            <li><a href="@Url.Action("LoginOut","Home")">注销</a></li>
                        </ul>
                    </li>
                    <li>
                        <i class="icon iconfont">&#xe698;</i>
                        <span style="background-color:#84AE6B;">8</span>
                        <div class="dropdown-menu" style="right:110px;height:200px;width:220px;">
                            <div class="head" style="background-color:#ECF2F7"><i class="icon iconfont" style="font-size:16px;color:#84AE6B;">&#xe698;</i>5个邮件消息</div>
                            <div class="body" style="height:140px;">
                                <div>进度1</div>
                                <div>进度2</div>
                                <div>进度3</div>
                            </div>
                            <div class="foot" style="height:30px;text-align:center">进入我的邮件</div>
                        </div>
                    </li>
                    <li>
                        <i class="icon iconfont" style="font-size:17px">&#xe69a;</i>
                        <span style="background-color:#d15b47;">15</span>
                        <div class="dropdown-menu" style="right:170px;height:200px;width:220px;">
                            <div class="head" style="background-color:#ECF2F7"><i class="icon iconfont" style="font-size:16px;color:#d15b47;">&#xe69a;</i>18个通知提醒</div>
                            <div class="body" style="height:140px;">
                                <div>通知1</div>
                                <div>通知2</div>
                                <div>通知3</div>
                            </div>
                            <div class="foot" style="height:30px;text-align:center">进入通知待办</div>
                        </div>
                    </li>
                    <li><i class="icon iconfont">&#xe62a;</i><span style="background-color:#a0a0a0;">4</span></li>
                </ul>
            </div>
        </div>
        <div class="messagebar">
            <div class="left" style="text-align:center;padding-left:40px;">
                <span class="accordion-text">导航菜单</span><span id="accordionswitch" class="accordion-open" onclick="showorclosemenu(this)"></span>
            </div>
            <div class="right">

            </div>
        </div>
    </div>

    <div id="indexcontent" class="index-content">
        <div class="left" style="border-right:1px solid #cccccc;border-top:1px solid #cccccc;">
            <ul class="menu-accordion">
                @helper ShowTree(MenuCatalog catalogs)
                {
                <ul>
                    @foreach (var node in catalogs.Menus.OrderBy(a => a.Order))
                    {                  
                            <li style="height:25px;line-height:25px;"><a data-menu="'Id':'@node.Id','Name':'@node.Name','title':'@node.Description','url':'@Url.Content(node.MenuURL)','IconText':'@node.IconText','IconColor':'@node.IconColor'" class="menunode">@node.Name</a></li>                       
                    }
                    @foreach (var catalog in catalogs.CataLogs)
                    {
                        <li>
                            <div style="width:100%;text-align:left;height:25px;line-height:25px;color:#7B8AB5;font-size:14px;">@catalog.Name</div>
                            @ShowTree(catalog)
                        </li>
                    }
                </ul>
}
                @{
                    foreach (var entity in Model)
                    {
                        <li class="node">
                            <i class="icon iconfont" style="color:@entity.IconColor">@MvcHtmlString.Create(entity.IconText)</i><a class="text">@entity.Name</a>
                            <div class="content hide">
                                <span style="font-size:16px;color:#7B8AB5">@entity.Name</span>
                                @ShowTree(entity)
                            </div>
                        </li>
                    }
                }
            </ul>
        </div>

        <div class="right">
            <div class="itemiframe" id="itemiframe">
                <iframe id="frame_0" class="selected" src="@Url.Content("~/Customer/CustomerInfo/Index")" frameborder="0"></iframe>
            </div>
        </div>
    </div>
    <div class="index-foot">客户信息云平台 version 1.0 技术支持 积微物联</div>
</body>
</html>
<script type="text/javascript">
    function IsinRange(e, _obj) {
        if (typeof (_obj) == "string") {
            _obj = document.getElementById(_obj);
        }
        e = e || window.event;
        var _hg = _obj.clientHeight;
        var _wd = _obj.clientWidth;
        var t = _obj.offsetTop;
        var l = _obj.offsetLeft;
        while (_obj = _obj.offsetParent) {
            t += _obj.offsetTop;
            l += _obj.offsetLeft;
        }
        if (e.clientX > _wd + l || e.clientY > t + _hg || e.clientX < l || e.clientY < t) {
            return false;
        }
        else {
            return true;
        }
    }
    $(".menu-accordion .node").mouseover(function (e) {
        $(this).find(".content").removeClass("hide");
    }).mouseout(function (e) {
        $(this).find(".content").addClass("hide");
        //var d = $(this).find(".content")[0];
        //var y = $(this)[0];
        //if (!IsinRange(e, y) && !IsinRange(e, d))
        //{
        //    $(this).find(".content").addClass("hide");
        //}
    });
    $(".menunode").click(function (e) {
        var menunode = $(this).attr("data-menu");
        menunode = JSON.parse("{" + menunode.replace(/'/g, '"') + "}");
        var tag = {
            id: "tag_" + menunode.Id,
            name: menunode.Name
        }, frame = {
            id: "frame_" + menunode.Id,
            name: menunode.Name,
            url: menunode.url
        };
        var animationclass = KingsSharp.Animation("in");
        if ($("#" + tag.id).size() == 0 || $("#" + frame.id).size() == 0) {
            $("#taglist .selected").removeClass("selected");
            $("#taglist").append("<li title=\"" + menunode.title + "\" onclick=\"Showtag('" + menunode.Id + "')\" id=\"" + tag.id + "\" class=\"selected " + animationclass + "\"><i class=\"icon iconfont\" style=\"color:" + menunode.IconColor + "\">" + menunode.IconText + "</i>" + tag.name + "<span class=\"close\" title=\"关闭\" onclick=\"CloseTag('" + menunode.Id + "')\">x</span></li>");
            $("#itemiframe .selected").removeClass("selected");
            $("#itemiframe").append("<iframe id=\"" + frame.id + "\" class=\"selected " + animationclass + "\" src=\"" + frame.url + "\" frameborder=\"0\"></iframe>");
        }
        else {
            $("#taglist .selected").removeClass();
            $("#itemiframe .selected").removeClass();
            $("#" + tag.id).addClass("selected " + animationclass);
            $("#" + frame.id).addClass("selected " + animationclass);
        }
        //alert($(this).parents(".content").html());
        $(this).parents(".content").addClass("hide");
    });
    function Showtag(id, isclose) {
        var animationclass = KingsSharp.Animation("in");
        if (!isclose) {
            $("#taglist .selected").removeClass();
            $("#itemiframe .selected").removeClass();
            $("#tag_" + id).addClass("selected " + animationclass);
            $("#frame_" + id).addClass("selected " + animationclass);
        }
        else {
            $("#tag_" + id).addClass("selected " + animationclass);
            $("#frame_" + id).addClass("selected " + animationclass);
        }
    }
    function CloseTag(id) {
        var previd = $("#tag_" + id).prev().attr("id").split('tag_')[1];
        $("#tag_" + id).addClass(KingsSharp.Animation("out"));
        $("#tag_" + id).remove();
        $("#frame_" + id).remove();
        Showtag(previd, true);
        KingsSharp.StopEvent(event);
    }
    function showorclosemenu(obj) {
        var mclass = $(obj).prop("class");
        if (mclass == "accordion-open") {
            $(obj).removeClass();
            $(obj).addClass("accordion-close");
            $("#indexcontent").addClass("index-content-close");
        }
        else {
            $(obj).removeClass();
            $(obj).addClass("accordion-open");
            $("#indexcontent").removeClass("index-content-close");
        }
    }
    $(".infobar li").click(function (e) {
        var menu = $(this).find(".dropdown-menu");
        menu.toggle();
        KingsSharp.StopEvent(e);
    });
    //修改密码
    $("#updatePwd").click(function () {
        //页面层
        layer.open({
            type: 1,
            title: '修改密码',
            skin: 'layui-layer-rim', //加上边框
            area: ['30%', '50%'], //宽高
            shadeClose: true,
            content: '<form class="updatePwd_form" onsubmit="return EditPwd()" id="Editform"><div style="margin:auto"><label class="sp">&#12288;旧密码:</label><input class="txt" type="password" id="oldPwd" name="oldPwd"/>\
                </div><div><label class="sp">&#12288;新密码:</label><input class="txt" type="password" name="Pwd" id="Pwd" />\
                </div><div><label class="sp">再次输入:</label><input class="txt" type="password" name="RegPwd" id="RegPwd"/></div>\
                 <div class="btn"><input type="submit"  class="editbtn" value="修改"  />\
                <input type="reset" class="regbtn" value="重置"/></div></form>'
        });
    });
    function EditPwd() {
        if (!$("#oldPwd").val()) {
            K.Alert("旧密码不能为空");
            return false;
        } else if (!$("#Pwd").val()) {
            K.Alert("新密码不能为空");
            return false;
        } else if ($("#Pwd").val().length < 5) {
            K.Alert("密码最小长度为5");
            return false;
        } else if (!$("#RegPwd").val()) {
            K.Alert("重复密码不能为空");
            return false;
        } else if ($("#Pwd").val() != $("#RegPwd").val()) {
            K.Alert("重复密码有误");
            return false;
        }
        Update();
        return false;

    }
    function Update() {
        var oldPwd = $("#oldPwd").val();
        var Pwd = $("#Pwd").val();
        K.AjaxJson("@Url.Content("~/Sys/User/EditPwd")", { 'oldPwd': oldPwd, 'Pwd': Pwd }, function (result) {
            if (result == 0) {
                K.Alert("修改失败");
            } else if (result == 1) {
                K.Alert("修改成功，新密码将在下次登陆生效");
                window.location.href = "/Home/Index";
            } else if (result == 2) {
                K.Alert("旧密码有误");
            }

        });
    }
</script>

